package cn.rkylin.oms.system.shop.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.system.shop.domain.ShopStor;
import cn.rkylin.oms.system.shop.vo.ShopStorVO;

/**
 * 店铺仓库dao层实现
 */
@Repository(value = "shopStorDAO")
public class ShopStorDAOImpl implements IShopStorDAO {
    // 常量定义
    private static final String STMT_DELETE_SHOPSTOR = "deleteByPrimaryKeyShopStor";
    private static final String STMT_UPDATE_SHOPSTOR = "updateByPrimaryKeySelectiveShopStor";
    private static final String STMT_INSERT_SHOPSTOR = "insertShopStor";
    private static final String STMT_SELECT_ONE_SHOPSTOR = "selectOneShopStor";
    private static final String STMT_UPDATE_SELECT_SHOPSTOR = "updateBySelectiveShopStor";
    
    @Autowired
    protected IDataBaseFactory dao;
    
    /**
     * 根据主键删除
     * @param shopStorId
     * @return
     */
    @Override
    public int deleteByPrimaryKey(String shopStorId) throws Exception {
        return dao.delete(STMT_DELETE_SHOPSTOR, shopStorId);
    }

    /**
     * 插入店铺仓库
     * @param record
     * @return
     */
    @Override
    public int insert(ShopStor shopStor) throws Exception {
        return dao.insert(STMT_INSERT_SHOPSTOR, shopStor);
    }

    /**
     * 根据主键获取1个店铺仓库
     * @param shopStorId
     * @return
     */
    @Override
    public ShopStor selectByPrimaryKey(String shopStorId) throws Exception {
        return dao.findOne(STMT_SELECT_ONE_SHOPSTOR, shopStorId);
    }
    
    @Override
    public ShopStor selectShopStorInfoByShopStor(ShopStorVO shopStorVO) throws Exception {
        return dao.findOne("selectShopStorInfoByShopStor", shopStorVO);
    }

    /**
     * 根据主键，选择性的进行更新
     * @param record
     * @return
     */
    @Override
    public int updateByPrimaryKeySelective(ShopStor shopStor) throws Exception {
        return dao.update(STMT_UPDATE_SHOPSTOR, shopStor);
    }

    @Override
    public int updateCleanDefaultReturnStorByShopStor(ShopStor param) throws Exception {
        return dao.update(STMT_UPDATE_SELECT_SHOPSTOR, param);
    }

}
